home *** CD-ROM | disk | FTP | other *** search
- /* *********************************************************************************
-
- MODULE: SaveEmail Module
-
- DESCRIPTION: This SaveEmail Module is a simple module for MUBBS, the
- Multi-User Bulliten Board System Software.
-
- AUTHOR: Noam Freedman
-
- Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
-
- This program source code and it's compiled version IS NOT IN THE
- PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
- regarding use of this program source code and it's compiled version.
-
- Revision History:
- ============================================================
- 8/30/91 - Started programming
- 11/ 4/91 - Edited for release
- ============================================================
-
-
- ******************************************************************************** */
-
-
- #define INMAIN
-
- #include "Email.h"
- #include "MUBBS Module.h"
- #include <SetUpA4.h>
-
- pascal void main (mode1,G1,P1)
- int mode1;
- struct GS *G1;
- Ptr P1;
- {
- Handle temph;
- float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
- RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
- asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
-
- G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
- mode[u]=mode1; /* set up our mode so that you can read it anywhere */
-
- switch (mode[u]) { /* any un-handled modes return error from this module */
- case 3:
- saveemail(P1);/* mode 3 because we are passing a user pointer */
- G->moduleresult=0;
- break;
- case 98:
- versionck(version); /* just return after this call, don't modify anything */
- break;
- case 0:
- strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
- G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
- break;
- default:
- G->moduleresult=1; /* return bad code */
- };
-
- HUnlock(temph); /* unlocks this module, do this ! */
- RestoreA4(); /* call this when you are all done */
- }
-
-
- saveemail(S)
- struct EnterStruct *S;
- {
- char PAD[100]; /* padding to cover a glitch */
- struct MsgStruct MsgInfo;
- struct FixStruct fixinfo;
- FILE *fp_headers, *fp_text;
- int a,i,num;
- long int temp,tempa;
-
- if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
-
- if (S->result==0) { /* if there's no "enter" made then quit */
- num=1;
- goto byebye;
- }
-
-
- strcpy(MsgInfo.FromUser,S->FromUser);
- strcpy(MsgInfo.ToUser,S->ToUser);
- strcpy(MsgInfo.title,S->title);
- strcpy(MsgInfo.NetAddress,S->NetAddress);
- strcpy(MsgInfo.temp,"NOAM");
- MsgInfo.status = UNREAD;
- getdatetime(MsgInfo.DateSent);
- if ( (fp_headers = fopen(":msgs:email.headers","a")) == NULL )
- {
- send("]]Can't open the file: %s]",":msgs:email.headers");
- send("]Your e-mail could not be saved.]");
- pause();
- num = 3;
- goto byebye;
- }
- else
- {
- if ( (fp_text = fopen(":msgs:email.data","a")) == NULL )
- {
- send("]]Can't open the file: %s]",":msgs:email.data");
- send("Your e-mail could not be saved.]");
- pause();
- num = 3;
- goto byebye;
- }
- else
- {
- temp = ftell(fp_text);
- for (i=0;i<=S->numlines && i < 49;i++)
- {
- for (a = 0;a<=79;a++)
- {
- if (S->emailtext[i][a] != '\0')
- fputc(S->emailtext[i][a],fp_text);
- else
- {
- a = 81;
- fputc('\n',fp_text);
- }
- }
- }
- fputc('~',fp_text); /* mark the end */
- tempa = ftell(fp_text);
- fixinfo.offset= temp;
- fixinfo.length= tempa - temp;
- fwrite( &fixinfo.offset, sizeof(fixinfo), 1, fp_text); /* write the data incase of fix */
- tempa = ftell(fp_text);
- fclose(fp_text);
- MsgInfo.offset = temp;
- MsgInfo.length = tempa - temp;
- S->offset = temp;
- S->length = tempa - temp;
- fwrite( &MsgInfo.FromUser[0], sizeof(MsgInfo), 1, fp_headers);
- fclose(fp_headers);
- send("]Email sent to \"%s\"]",MsgInfo.ToUser);
- }
- }
- byebye:
- S->result = num;
- }
-